<?php

/**
 * Description of Bericht
 * @author Nick
 */

require_once '/../classes/db/Database.php';

class Bericht extends Database {
    
   private $Bericht_ID;
   private $Naam = '';
   private $Bericht = '';
   
   function __construct() {
       
   }

   
   public function getBericht_ID() {
       return $this->Bericht_ID;
   }

   public function setBericht_ID($Bericht_ID) {
       $this->Bericht_ID = $Bericht_ID;
   }

   public function getNaam() {
       return $this->Naam;
   }

   public function setNaam($Naam) {
       $this->Naam = $Naam;
   }

   public function getBericht() {
       return $this->Bericht;
   }

   public function setBericht($Bericht) {
       $this->Bericht = $Bericht;
   }
   
   public function checkLogin($username, $password){      
        
         if($this->dbquery("SELECT * FROM `gebruiker` WHERE `Username` = '$username' AND `Paswoord` = '$password'")) {
            
             // Controle of er iets gevonden is in de database
             if($this->dbNumRows() == 1){
                 return $this->dbFetchAll();
                 
             } else {
                 return FALSE;
             }    
                   
         } else {
             throw new Exception ("DB_ERROR_COULDNOTSELECT");
         }
          

          if (DEBUG_LVL & DEBUG_LVL_QUERY)  echo __FILE__ . ' ' . __LINE__ .': ' .$query . '<br />';
        
        $this->reset();
    }
    
    public function addGeregistreerdeGebruiker($username, $paswoord, $email, $secret_question, $secret_answer){
        
              if (
             
            !empty ($username)
               
            ){
           
            $query = "INSERT INTO `robotik`.`gebruiker` (`Username`, `Paswoord`, `Email`, `Secret_Question`, `Secret_Answer`)
                        VALUES (                        
                            '" . mysql_real_escape_string($username) . "',
                            '" . mysql_real_escape_string($paswoord) . "', 
                            '" . mysql_real_escape_string($email) . "',
                            '" . mysql_real_escape_string($secret_question) . "',
                            '" . mysql_real_escape_string($secret_answer) . "'
                            )";
                             
            if (DEBUG_LVL & DEBUG_LVL_QUERY)  echo __FILE__ . ' ' . __LINE__ .': ' .$query . '<br />';
            
            if (!$this->dbquery($query)){
 
               throw new Exception("DB_ERROR_NIETVERWERKT");
      
            }
  
            return TRUE;
        }
        else {
          throw new Exception("DB_ERROR_INVOERFOUT");
        }
        
    }


   
    
}

?>
